
const path = require('path')
//第二种方法,1.在package.json的sacipts添加"dev2": "webpack-dev-server"
//2.要导入webpack
const webpack =require('webpack')
module.exports={
    entry:path.join(__dirname,'src/main.js'),
    output:{
        path:path.join(__dirname,'dist'),
        filename:'bundle.js'
    },
    mode:'development',
    //3.第二种方法引入这些对象
    devServer:{
        open:true,
        port:8888,
        hot:true,
        contentBase:'./src'
    },
    //4.配置热更新
    plugins:[
        new webpack.HotModuleReplacementPlugin()
    ],
    //样式文件正则匹配
    module:{
        rules:[
            {test:/\.css$/,use:['style-loader','css-loader']},
            {test:/\.less$/,use:["style-loader","css-loader","less-loader"]},
            {test:/\.scss$/,use:["style-loader","css-loader","less-loader",'sass-loader']},
            { test: /\.(png|jpg|gif)$/, use: 'url-loader' }
        ]  
    } 

}